package com.hotel.service.impl;

import com.hotel.mapper.CartMapper;
import com.hotel.pojo.Cart;
import com.hotel.service.CartService;
import com.hotel.vo.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CartServiceImpl implements CartService {
    @Autowired
    private CartMapper cartMapper;

    @Override
    public PageResult cartList(PageResult pageResult) {
        Long total=cartMapper.getTotal();
        int size=pageResult.getPageSize();
        int start=(pageResult.getPageNum()-1)*size;
        String query = pageResult.getQuery();
        List<Cart> rows=cartMapper.findCartListByPage(start,size,query);
        return pageResult.setTotal(total).setRows(rows);
    }
}
